﻿using Game.Map;

namespace Game.Ai.Internal.States
{
    class StateUtil
    {

        public static bool InAdjacentField(
            AiController ai,
            IMapField field,
            IMapField vehicleField)
        {
            bool adjacent = false;
            foreach (var af in MapUtil.GetAdjacentFields(ai.GameMap, vehicleField.Point))
            {
                if (af.Point.X == vehicleField.Point.X &&
                    af.Point.Y == vehicleField.Point.Y)
                {
                    continue;
                }

                if (af.Point.X == field.Point.X &&
                    af.Point.Y == field.Point.Y)
                {
                    adjacent = true;
                }
            }

            return adjacent;
        }

    }
}
